package algorithm.poj.p3000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;
import java.util.StringTokenizer;


/**
 * 分析：
 * 实现：
 * 经验：
 * 教训：
 * 分类：数学问题
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P3219 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P3219.class.getResource("P3219.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine();
		StringBuffer sb = new StringBuffer("");
		while (line != null) {
			StringTokenizer st = new StringTokenizer(line);
			int n = Integer.valueOf(st.nextToken());
			int k = Integer.valueOf(st.nextToken());
			if (pow2(n) > pow2(k) + pow2(n-k)) {
				sb.append("0\n");
			} else {
				sb.append("1\n");
			}
			line = stdin.readLine();
		}
		System.out.println(sb);
	}
	
	private static int pow2(int n) {
		int c = 0;
		while (n > 1) {
			n /= 2;
			c += n;
		}
		return c;
	}
}
